<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0,minimum=1.0,user-scalable=no">
    <title>Title</title>
    <link href="https://cdn.bootcss.com/mui/3.7.1/css/mui.min.css" rel="stylesheet" >
    <script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
</head>
<body>





<div class="mui-content">
    <h3 class="mui-content-padded">发送消息</h3>
    <div class="mui-card">
        <form class="mui-input-group">

            <div class="mui-input-row" style="height: auto;">
                <textarea id="textarea" rows="5" placeholder="输入消息"></textarea>
            </div>
            <div class="mui-input-row mui-checkbox">
                <label>李俊强</label>
                <input name="userID" value="LiJunQiang" type="checkbox" >
            </div>
            <div class="mui-input-row mui-checkbox">
                <label>刘士卡</label>
                <input name="userID" value="liushika" type="checkbox">
            </div>
            <div class="mui-input-row mui-checkbox">
                <label>庞国庆</label>
                <input name="userID" type="checkbox" value="pangguoqing">
            </div>
            <div class="mui-input-row mui-checkbox">
                <label>鞠超群</label>
                <input name="userID" type="checkbox" value="1qaz2wsx">
            </div>
        </form>
        <div class="mui-content-padded">
            <button type="button" class="mui-btn mui-btn-warning mui-btn-block" style="padding:10px 0;" id="sendEmp">发送消息</button>
        </div>
    </div>
</div>


<button type="button" class="mui-btn mui-btn-danger mui-btn-block" id="sendDept">发送给部门消息</button>

<script>


    $(function () {

        $("#sendEmp").click(function () {

            var userIDs = ""
            $.each($('input:checkbox:checked'),function(){

                userIDs+=$(this).val()+"|";
            });

            userIDs = userIDs.substring(0,userIDs.length-1);

            var textarea = $('#textarea').val();

            $.post("/send",{"content":textarea,"userID":userIDs},function (result) {
                alert(JSON.parse(result).errmsg);
            });
            return false;
        });

        $("#sendDept").click(function () {
            var textarea = $('#textarea').val();
            $.post("/send", {"content":textarea,"deptID":1},function (result) {
                alert(JSON.parse(result).errmsg);
            });
            return false;
        });

    });




</script>


</body>
</html>